From 11e22aadda28160d8c62438c7af3cec0d8b054d5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 31 May 2016 22:05:58 -0400 Subject: [PATCH] wayland: Better debug info for scroll axes Print human readable names for axes and axis sources. --- gdk/wayland/gdkdevice-wayland.c | 52 ++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 1e3bc8336e..887b7ee721 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1429,6 +1429,24 @@ pointer_handle_button (void *data, gdk_wayland_seat_flush_frame_event (seat); } +#ifdef G_ENABLE_DEBUG + +const char * +get_axis_name (uint32_t axis) +{ + switch (axis) + { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + return "horizontal"; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + return "vertical"; + default: + return "unknown"; + } +} + +#endif + static void pointer_handle_axis (void *data, struct wl_pointer *pointer, @@ -1459,8 +1477,8 @@ pointer_handle_axis (void *data, seat->pointer_info.time = time; GDK_NOTE (EVENTS, - g_message ("scroll, axis %d, value %f, seat %p", - axis, wl_fixed_to_double (value) / 10.0, + g_message ("scroll, axis %s, value %f, seat %p", + get_axis_name (axis), wl_fixed_to_double (value) / 10.0, seat)); if (display->seat_version < WL_POINTER_HAS_FRAME) @@ -1479,6 +1497,26 @@ pointer_handle_frame (void *data, gdk_wayland_seat_flush_frame_event (seat); } +#ifdef G_ENABLE_DEBUG + +static const char * +get_axis_source_name (enum wl_pointer_axis_source source) +{ + switch (source) + { + case WL_POINTER_AXIS_SOURCE_WHEEL: + return "wheel"; + case WL_POINTER_AXIS_SOURCE_FINGER: + return "finger"; + case WL_POINTER_AXIS_SOURCE_CONTINUOUS: + return "continuous"; + default: + return "unknown"; + } +} + +#endif + static void pointer_handle_axis_source (void *data, struct wl_pointer *pointer, @@ -1492,11 +1530,11 @@ pointer_handle_axis_source (void *data, /* We don't need to handle the scroll source right now. It only has real * meaning for 'finger' (to trigger kinetic scrolling). The axis_stop * event will generate the zero delta required to trigger kinetic - * scrolling, so explicity handling the source is not required. + * scrolling, so explicitly handling the source is not required. */ GDK_NOTE (EVENTS, - g_message ("axis source %d, seat %p", source, seat)); + g_message ("axis source %s, seat %p", get_axis_source_name (source), seat)); } static void @@ -1528,7 +1566,7 @@ pointer_handle_axis_stop (void *data, pointer_frame->is_scroll_stop = TRUE; GDK_NOTE (EVENTS, - g_message ("axis stop, seat %p", seat)); + g_message ("axis %s stop, seat %p", get_axis_name (axis), seat)); } static void @@ -1556,8 +1594,8 @@ pointer_handle_axis_discrete (void *data, } GDK_NOTE (EVENTS, - g_message ("discrete scroll, axis %d, value %d, seat %p", - axis, value, seat)); + g_message ("discrete scroll, axis %s, value %d, seat %p", + get_axis_name (axis), value, seat)); } static void -- 2.30.2